import static org.junit.Assert.*;

import org.junit.Test;

import com.hamishmedlin.d64pw.CheckPassCodeHolder;
import com.hamishmedlin.d64pw.Fields;
import com.hamishmedlin.d64pw.QEncoder;


public class QEncoderTest {

	@Test
	public void testIntDivide() {
		Fields fields = new Fields();
		fields.setNextMap(1);
		fields.setBackpack(true);
		fields.setClip(50);
		
		assertEquals("BX01 ?BKP 8?NK 1VK?", QEncoder.encodePassword(fields));
	}
	
	@Test
	public void testCheckPassCode(){
		int[] temp = new int[]{4,155,223,0,219,223,100,251,64,255};
		CheckPassCodeHolder test = QEncoder.checkPassCode(0, 0, temp);
		
		assertFalse(test.getCheck());
		assertEquals(0, test.getValue(1));
		assertEquals(0, test.getValue(2));
		assertEquals(0, test.getValue(3));
	}
	
	@Test
	public void testCheckPassCode2(){
		int[] temp = new int[]{4,155,223,0,219,223,100,251,64,255};
		CheckPassCodeHolder test = QEncoder.checkPassCode(4, 0, temp);
		assertFalse(test.getCheck());
		assertEquals(4, test.getValue(1));
		assertEquals(0, test.getValue(2));
		assertEquals(4, test.getValue(3));
	}

}